using System.Web.Mvc;
using AddressBook.Models;
using ManagedUIFlow.Infrastructure.Commands.FlowActionHelpers;

namespace AddressBook.Controllers
{
    public class DetailsController : FlowController
    {
        private readonly PersonRepository _personRepository;

        public DetailsController()
        {
            _personRepository = new PersonRepository();
        }

        //
        // GET: /Details/

        public ActionResult Process()
        {
            var person = _personRepository.FindBy(1);

            if (person == null)
            {
                ViewData.Model = new SearchViewModel { ErrorMessage = "Perosn details not found." };
                return State("error");
            }

            ViewData.Model = new SearchViewModel { Person = person };

            return State("done");
        }
    }
}
